package lambda;

import java.util.Arrays;
import java.util.Comparator;

public class demo4 {
    public static void main(String[] args) {
        String[] arr = {"aaa", "a", "aaaa", "aaaaaa"};
        Arrays.sort(arr, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                int len1 = o1.length();
                int len2 = o2.length();
                return len1 - len2;
            }
        });
        System.out.println(Arrays.toString(arr));//[scc, ldszs, kdcsxs, fehkpds]

    }
}
